package defectsim.resources.deformation;

import repast.simphony.parameter.Parameters;
import defectsim.SimulationEnvironment;

public class DeformationFactory {
	
	public enum DeformationMode {
		CyclicStress,
		CyclicStrain,
		MonotonicStress,
		ConstantStress
	}
	private SimulationEnvironment environment = SimulationEnvironment.getInstance();
	
	public Deformation createDeformation(DeformationMode deformationMode) {
		switch (deformationMode) {
		case CyclicStress :
			Parameters p = environment.getParameters();
			int cyclicTickCount = (Integer)p.getValue("cyclictickcount");
			double maxExternalStress = (Double)p.getValue("externalstress");;
			return new CyclicStress(cyclicTickCount, maxExternalStress);
		case CyclicStrain :
			return new CyclicStrain();
		case MonotonicStress :
			return new MonotonicStress();
		case ConstantStress :
			return new ConstantStress();
		}
		throw new IllegalArgumentException("The deformation mode " + deformationMode + " is not recognized.");
	}
}
